/******************** 变量 ********************/
$lv-badge-color-white: #ffffff !default;
$alarm-color-info: #f2ed5a !default;

$lv-badge-normal-bg-color: $error-color !default;
$lv-badge-default-bg-color: $alarm-color-info !default;
$lv-badge-success-bg-color: $success-color !default;
$lv-badge-processing-bg-color: $alarm-color-info !default;
$lv-badge-warning-bg-color: $alarm-color-minor !default;
$lv-badge-error-bg-color: $error-color !default;

/******************** mixin ********************/
@keyframes statusProcessing {
  0% {
    -webkit-transform: scale(0.8);
    transform: scale(0.8);
    opacity: 0.8;
  }

  to {
    -webkit-transform: scale(2.4);
    transform: scale(2.4);
    opacity: 0;
  }
}

/******************** 组件 ********************/
.lv-badge {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  color: $text-color;
  font-size: $font-size-base;
  font-family: $font-family;
  line-height: $line-height-base;

  > .lv-badge-dot {
    position: relative;
    display: inline-block;
    box-sizing: content-box;
    width: 0.06rem;
    height: 0.06rem;
    background: $lv-badge-normal-bg-color;
    border: $border-width-base $border-style-base $badge-border-color;
    border-radius: $border-radius-circle;
  }

  > .lv-badge-label {
    padding-left: $padding-sm;
  }

  > .lv-badge-status-default {
    background: $lv-badge-default-bg-color;
  }

  > .lv-badge-status-success {
    background: $lv-badge-success-bg-color;
  }

  > .lv-badge-status-warning {
    background: $lv-badge-warning-bg-color;
  }

  > .lv-badge-status-error {
    background: $lv-badge-error-bg-color;
  }

  > .lv-badge-status-processing {
    background: $lv-badge-processing-bg-color;

    &::after {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      border: $border-width-base $border-style-base $lv-badge-processing-bg-color;
      border-radius: 50%;
      animation: statusProcessing 1.2s infinite ease-in-out;
      content: '';
    }
  }

  .lv-badge-circle {
    display: inline-flex;
    align-items: flex-start;
    justify-content: flex-start;
    box-sizing: content-box;
    width: 0.14rem;
    height: 0.14rem;
    padding: 0 0.03rem;
    overflow: hidden;
    color: $lv-badge-color-white;
    font-weight: $font-weight-bold;
    font-size: $font-size-sm;
    font-style: normal;
    line-height: 1;
    white-space: nowrap;
    background: $lv-badge-normal-bg-color;
    border: $border-width-base $border-style-base $badge-border-color;
    border-radius: $border-radius-lg;
    transform-origin: center center;
    transition: padding $motion-duration-md $motion-func-ease;
    user-select: none;

    &-multi {
      width: auto;
      padding: 0 $padding-xs;
    }

    .lv-badge-value {
      flex: 1;
      height: 2rem;
      transform: translateY(0%);
      margin-top: -0.03rem;

      p {
        color: inherit;
        line-height: 0.2rem;
        height: 0.2rem;
        white-space: normal;
        text-align: center;
        word-break: break-all;
      }
    }
  }
}

.lv-badge-wrapper {
  position: relative;
  z-index: $zindex-badge-default;

  > .lv-badge {
    position: absolute;
    top: -0.08rem;
    left: calc(100% - 0.08rem);
    z-index: $zindex-badge;

    &.lv-badge-round {
      top: -0.04rem;
      left: calc(100% - 0.04rem);
    }
  }
}

.lv-badge-max {
  height: 0.2rem;
  line-height: 0.2rem;
  margin-top: -0.03rem;
}

.lv-badge-plus {
  box-sizing: border-box;
  padding-left: 0.01rem;
  line-height: 0.2rem;
  transform: translateY(0);
  margin-top: -0.03rem;

  &-hidden {
    width: 0;
    height: 0;
  }
}
